/*
 * hero.h
 *
 *  Created on: 26.12.2012
 *      Author: Michael
 */

#ifndef HERO_H_
#define HERO_H_

#define DIMENSION 10

// The direction in which the hero looks
enum Direction { NORTH, EAST, SOUTH, WEST };

// Position in the maze
struct Position {
	unsigned int x;
	unsigned int y;
	Direction direction;
};

// Definition of the maze signs
struct Signs {
	char wall;
	char path;
	char exit;
	char breadcrump;
};

// Definition of the hero which tries to escape the maze
class Hero {
private:
	Position _start;
	Position _curr;
	Signs _signs;

public:

	/*
	 * Create a new Hero.
	 * start: The start position in the maze
	 * signs: The signs used for defining the maze
	 */
	Hero(Position start, Signs signs){
		_start = start;
		_signs = signs;
	}

	/*
	 * Destructor
	 */
	~Hero(){

	}

	/*
	 * Escape from the maze.
	 * maze: The maze to escape from
	 * showProgress: If set to true the maze will be printed after every step
	 */
	void escape(char maze[DIMENSION][DIMENSION], bool showProgress);

private:

	/*
	 * Escape in a recursive way
	 * curr: The current position of the hero
	 * maze: The maze to escape from
	 * showProgress: If set to true the maze will be printed after every step
	 * return: True if exit was found
	 */
	bool doEscape(Position curr, char maze[DIMENSION][DIMENSION], bool showProgress);

	/*
	 * Print the maze.
	 * maze: The maze to print
	 */
	void print(char maze[DIMENSION][DIMENSION]);

	/*
	 * Get the position on the left side.
	 * curr: The current position
	 * return: The position on the left side
	 */
	Position getLeft(Position curr);

	/*
	 * Get the position on the right side.
	 * curr: The current position
	 * return: The position on the right side
	 */
	Position getRight(Position curr);

	/*
	 * Get the position on the front.
	 * curr: The current position
	 * return: The position on the front
	 */
	Position getFront(Position curr);

	/*
	 * Get the position on the back.
	 * curr: The current position
	 * return: The position on the back
	 */
	Position getBack(Position curr);
};


#endif /* HERO_H_ */
